package cc.jorange.dao;

import java.util.List;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import cc.jorange.bean.Permission;

/**
 * 
 * @author Aaron
 *
 */
public interface PermissionDao extends PagingAndSortingRepository<Permission, Long> {

	@Query("from Permission p where p.name=?1")
	List<Permission> getPermission(String name);
	
	@Query("from Permission p where p.name IN (?1)")
	List<Permission> getPermission(List<String> names);
	
	@Query(nativeQuery = true, value="SELECT GROUP_CONCAT(p.name) FROM ss_permission p WHERE p.id IN (?1)")
	String getPermissions(List<Long> ids);

}
